import { PageDateSelect } from '@/types/pages/enum';
import { IPurchase } from '@/types/pages/purchase/interface';
import Mock from 'mockjs'
import { IDateLineChart, IDatePieChart } from '@/types/echart';


/** 采购总额 */
export const getPurchaseNumData: (type: PageDateSelect, date?: Date) => Promise<IPurchase> = function (type: PageDateSelect, date?: Date) {
    return new Promise((res, rej) => {
        let data: IPurchase = {  name: '总量', totalNum: Mock.mock('@integer(10000, 50000)'), unit: '吨', num: Mock.mock('@integer(10000, 50000)'), saleRate: '5%', 'upDownStatus': Mock.mock('@boolean') ,comparisonText:'比去年'}
        res(Mock.mock(data));
    })

}
/** 采购总额 */
export const getPurchaseNumChart : (type: PageDateSelect, date?: Date) => Promise<IDatePieChart> = function (type: PageDateSelect, date?: Date) {
    return new Promise((res, rej) => { 
        const dataset: IDatePieChart = { title: '', dataset: { dimensions: ['名称', '类型'], 'source': [{ '名称': '榆林化学' + Mock.Random.cname(), '类型|1-100': 100, }, { '名称': '产品' + Mock.Random.cname(), '类型|1-100': 100, }, { '名称': '聚酯级' + Mock.Random.cname(), '类型|1-100': 100, }] } }
        res(Mock.mock(dataset));
    })

}
/** 物资采购占比 */
export const getMaterialPieChart: (type: PageDateSelect, date?: Date) => Promise<Partial<IDatePieChart>> = function (type: PageDateSelect, date?: Date) {
    return new Promise((res, rej) => {
        const dataset: IDatePieChart = { title: '物资采购占比', dataset: { dimensions: ['名称', '类型'], 'source': [{ '名称': '榆林化学' + Mock.Random.cname(), '类型|1-100': 100, }, { '名称': '产品' + Mock.Random.cname(), '类型|1-100': 100, }, { '名称': '聚酯级' + Mock.Random.cname(), '类型|1-100': 100, }] } }
        res(Mock.mock(dataset));
    })

}
/** 采购订单类型 */
export const getPurchaseTypePieChart: (type: PageDateSelect, date?: Date) => Promise<Partial<IDatePieChart>> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        const dataset: IDatePieChart = { title: '采购订单类型', dataset: { dimensions: ['名称', '类型'], 'source': [{ '名称': '产品' + Mock.Random.cname(), '类型|1-100': 100, }, { '名称': '产品' + Mock.Random.cname(), '类型|1-100': 100, }, { '名称': '聚酯级' + Mock.Random.cname(), '类型|1-100': 100, }] } }
        res(Mock.mock(dataset));
    })
} 

/** 物资采购金额top10 */
export const getMaterialColumnChart: (type: PageDateSelect, date?: Date) => Promise<Partial<IDateLineChart>> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        const a=()=>(Math.random()*100).toFixed(2)
        const dataset:IDateLineChart={title:'物资采购金额top10',dataset:{dimensions:['物资','数值'],source:[{'客户':Mock.Random.cname(),'数值':a()},{'物资':Mock.Random.cname(),'数值':a()},{'物资':Mock.Random.cname(),'数值':a()},{'物资':Mock.Random.cname(),'数值':a()}]}}
        res(Mock.mock(dataset));
    })
}

/** 单价变动幅度top10 */
export const getMaterialLineChart: (type: PageDateSelect, date?: Date) => Promise<Partial<IDateLineChart>> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        const a = () => (Math.random() * 100).toFixed(2)
        const dataset: IDateLineChart = { title: '单价变动幅度top10', dataset:{dimensions:['物资','数值'],source:[{'客户':Mock.Random.cname(),'数值':a()},{'物资':Mock.Random.cname(),'数值':a()},{'物资':Mock.Random.cname(),'数值':a()},{'物资':Mock.Random.cname(),'数值':a()}]}}
        res(Mock.mock(dataset));
    })
}


 




